﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


public class LifeSpanSystem : ECSSystemtBase
{
    public override Type[] GetFilter()
    {
        return new Type[]
        {
            typeof(LifeSpanCom),
        };
    }

    private List<ECSEntityBase> list;
    private LifeSpanCom lsc;
    public override void FixedUpdate(int delaTime)
    {
        list = GetEntityList();
        int listCount = list.Count;
        if (listCount<=0)
        {
            return;
        }
        for (int i = 0; i < listCount; i++)
        {
            lsc = list[i].GetCom<LifeSpanCom>();
            lsc.lifeTime -= delaTime;

            if (lsc.lifeTime<0)
            {
                MyWorld.ClientDestoryEntity(list[i].ID);
            }
        }
    }
}

